<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>电子合同</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/renting/css/public.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/renting/css/layui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/header.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/bottom.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/tenant_public.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/renting/css/tenant_contract.css"/>
</head>
<body>
<div class="header">
    <div class="nav">
        <a href="${pageContext.request.contextPath}/renting/index.jsp" class="nav_title">好客租房</a>
        <select class="select">
            <option value="重庆">重庆</option>
            <option value="贵阳">贵阳</option>
            <option value="重庆">重庆</option>
            <option value="贵阳">贵阳</option>
        </select>
        <ul class="nav_ul">
            <li><a href="${pageContext.request.contextPath}/renting/index.jsp">首页</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/Findroom.jsp">轻松找房</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/entry.jsp">房东入驻</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/chat_news.jsp">消息</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/onther/login.jsp" style="color: #2981c8;">登录</a></li>
        </ul>
        <img src="${pageContext.request.contextPath}/renting/img/icon/lianxi-1.png" class="nav_img" style="margin-top: -20px;">
        <p class="nav_phone">
            <span>13301131116</span>
            <span>13301131116</span>
        </p>
    </div>
</div>
<div class="body">
    <div class="portrait_bg">
        <div class="portrait">
            <a href="${pageContext.request.contextPath}/renting/pages/onther/personal.jsp" class="headImg">
                <img style="width: 100px;height: 100px;border-radius: 100%" src="../../img/${drom.avater}">
            </a>
        </div>
        <p class="nickname">点击头像编辑个人资料</p>
    </div>
    <div class="content">
        <ul class="left_ul">
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/inspection.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >看房记录</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/appointment.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >我的预约</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/order.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >我的订单</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/collection.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >我的收藏</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/wallet.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >我的钱包</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/ID_verification.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >身份验证</a></li>
            <li class="li_active"><a href="${pageContext.request.contextPath}/renting/pages/tenant/contract.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >电子合同</a></li>
            <li><a href="${pageContext.request.contextPath}/renting/pages/tenant/about.jsp"><img src="${pageContext.request.contextPath}/renting/img/xuanzhongtiao.png" >联系我们</a></li>
        </ul>
        <div class="right_body">
            <div class="right_content">
                <div class="right_title">
                    <p>已签合同</p>
                </div>
                <div class="stripe">
                    <span>合同名称</span>
                    <span>签约时间</span>
                    <span>签字人</span>
                    <span>操作</span>
                </div>
                <div id="addContent" class="right_main">

                </div>
            </div>
        </div>
        <div style="clear: both;"></div>
    </div>
</div>
<div class="bottom">
    <p>沪公网安备 31011402005354号</p>
</div>
</body>
</html>
<script src="${pageContext.request.contextPath}/renting/js/jQuery-3.4.1.js"></script>

<script>
    $(function (){
        var txt={"userId":${drom.rid},"confirm":"审核通过"};
        $.ajax({
            url:"${pageContext.request.contextPath}/contract/queryTenantContractViewLimit?limit=3&page=1",
            type:"post",
            data:"condition="+JSON.stringify(txt),
            dataType:"JSON",
            success:(rs)=>{
                $.each(rs.list,function (i,j){
                    var contractDate = j.contractDate;

                    if(contractDate!=null){
                        var date = new Date(contractDate);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
                        Y = date.getFullYear() + '-';
                        M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
                        D = date.getDate() + ' - ';
                        H = date.getHours() + ':';
                        Mi = date.getMinutes() + ':';
                        S = date.getSeconds();
                        contractDate = Y+M+D+H+Mi+S;
                    }
                    var a=contractDate.split(' - ');
                    var Listings=$('<div style="margin-top: 10px;border-bottom: 1px solid gray;overflow: hidden;line-height: 40px" class="con">' +
                        '<span style="float: left;margin-top: 20px;margin-left: 10px;border: 1px solid transparent;width: 200px;">租房合同</span>' +
                        '<div style="float: left;margin-left: 150px;border: 1px solid transparent;width: 100px;text-align: center;">' +
                        '<p>'+a[0]+'</p>' +
                        '<p>'+a[1]+'</p>' +
                        '</div>' +
                        '<span style="float: left;margin-top: 20px;margin-left: 120px;border: 1px solid transparent;width: 100px;text-align: center;">'+j.name+'</span>' +
                        '<span style="float: left;margin-left: 10px;border: 1px solid transparent;width: 200px;">' +
                        '<a style="text-decoration: none;color: cadetblue;margin-left: 120px" onclick="select('+j.rid+')" href="javascript:void(0)">查看信息</a><br>' +
                        '<a style="text-decoration: none;color: cadetblue;margin-left: 120px" onclick="cancel('+j.rid+')" href="javascript:void(0)">提前解约</a>' +
                        '</span>' +
                        '</div>');
                    Listings.appendTo("#addContent");
                })
            }
        });

    });

</script>
<script src="${pageContext.request.contextPath}/renting/layui.js"></script>
<script src="${pageContext.request.contextPath}/renting/js/header.js"></script>
<script src="${pageContext.request.contextPath}/layui/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script type="text/javascript">

    //查看合同
    select=function (rid) {
        var index = layer.open({
            title: "<a align='center' href='${pageContext.request.contextPath}/renting/index.jsp' class='nav_title'><b><span style='font-size:20px;'>房屋租赁合同</span></b></a>",
            type: 2,
            shade: 0.2,
            shadeClose: true,
            scrollbar: false,
            area: ['510px', '90%'],
            <%--content: '${pageContext.request.contextPath}/renting/pages/landlord/contract_show.jsp'--%>
            content: '${pageContext.request.contextPath}/contract/queryContractByLand?rid='+rid,
        });
    }
    //中断合约
    cancel=function (rid){
        layer.alert('合约结束前停止租约将赔付违约金', {
            icon: 0,
            btn:["确定,并下一步","取消"],
            skin: 'layer-ext-demo',
            btn1:function (){
                layer.msg(rid);//跳转违约金结算页面
            }
        })
    }

    judge_login("${pageContext.request.contextPath}/renting/pages/tenant/inspection.jsp","${pageContext.request.contextPath}/renting/pages/onther/login.jsp");
</script>
<script src="${pageContext.request.contextPath}/renting/js/ScrollHolder.js"></script>
